from collections import Counter
from typing import List


class Solution:
    def findOriginalArray(self, changed: List[int]) -> List[int]:
        ans = []
        count = Counter(changed)
        if 0 in count:
            if count[0] % 2 != 0:
                return []
            else:
                ans.extend([0] * (count[0] // 2))
                count[0] = 0

        for n1 in sorted(count.keys()):
            if count[n1] == 0:
                continue
            n2 = n1 * 2
            if n2 not in count:
                return []
            if count[n2] < count[n1]:
                return []
            count[n2] -= count[n1]
            ans.extend([n1] * count[n1])
        return ans


if __name__ == "__main__":
    print(Solution().findOriginalArray(changed=[1, 3, 4, 2, 6, 8]))  # [1,3,4]
    print(Solution().findOriginalArray(changed=[6, 3, 0, 1]))  # []
    print(Solution().findOriginalArray(changed=[1]))  # []

    # 测试用例 151/178
    print(Solution().findOriginalArray(changed=[0, 0, 0, 0]))  # [0,0]
